<html>
<head><meta charset="utf-8"><title>Drop with const_evaluatable_checked · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html">Drop with const_evaluatable_checked</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245016726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245016726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex O&#x27;Brien <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245016726">(Jul 06 2021 at 09:51)</a>:</h4>
<p>Per issue <a href="https://github.com/rust-lang/rust/issues/79248">#79248</a>, it's not currently possible to implement <code>Drop</code> for a type with a constrained const-generic parameter. I took a stab at fixing the issue just by calling <code>try_unify_abstract_consts</code> in <code>ensure_drop_predicates_are_implied_by_item_defn</code> for <code>PredicateKind::ConstEvaluatable</code>, but, while this seems to sort of work, I have no idea whether it's actually the correct thing to do.</p>



<a name="245016933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245016933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex O&#x27;Brien <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245016933">(Jul 06 2021 at 09:53)</a>:</h4>
<p>It does also provoke the following error:</p>
<div class="codehilite"><pre><span></span><code>error[E0367]: `Drop` impl requires `[(); _]: &#39;&lt;empty&gt;` but the struct it is implemented for does not
</code></pre></div>
<p>Which can be worked around by instead specifying <code>: Sized</code>, though I'm sure there's a better way to fix it.</p>



<a name="245017265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245017265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245017265">(Jul 06 2021 at 09:57)</a>:</h4>
<blockquote>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> would have to compare the explicit predicates for the struct and the impl and see where they differ (or if they do)</p>
</blockquote>
<p>when I brought up <a href="https://github.com/rust-lang/rust/issues/79248">#79248</a> lcnr said ^</p>



<a name="245017318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245017318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245017318">(Jul 06 2021 at 09:57)</a>:</h4>
<p>which kind of sounds like it might be what you're doing</p>



<a name="245017447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245017447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245017447">(Jul 06 2021 at 09:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="344214">Alex O'Brien</span> <a href="#narrow/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked/near/245016933">said</a>:</p>
<blockquote>
<p>It does also provoke the following error:</p>
<div class="codehilite"><pre><span></span><code>error[E0367]: `Drop` impl requires `[(); _]: &#39;&lt;empty&gt;` but the struct it is implemented for does not
</code></pre></div>
<p>Which can be worked around by instead specifying <code>: Sized</code>, though I'm sure there's a better way to fix it.</p>
</blockquote>
<p>this error is kind of interesting <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="245017546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245017546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245017546">(Jul 06 2021 at 10:00)</a>:</h4>
<p>Do you have your code pushed somewhere to look at?</p>



<a name="245018134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245018134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex O&#x27;Brien <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245018134">(Jul 06 2021 at 10:06)</a>:</h4>
<p>I only made a pretty tiny change. Patch is attached to this message. </p>
<p><a href="/user_uploads/4715/xU4nX8lWI4mJ3Dywtx2WB9Hf/0001-typeck-Allow-Drop-implementation-for-constrained-con.patch">0001-typeck-Allow-Drop-implementation-for-constrained-con.patch</a></p>



<a name="245018206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245018206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex O&#x27;Brien <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245018206">(Jul 06 2021 at 10:07)</a>:</h4>
<p>But yeah that error seemed pretty weird to me too.</p>



<a name="245018509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Drop%20with%20const_evaluatable_checked/near/245018509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex O&#x27;Brien <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked.html#245018509">(Jul 06 2021 at 10:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="326176">Boxy [she/her]</span> <a href="#narrow/stream/131828-t-compiler/topic/Drop.20with.20const_evaluatable_checked/near/245017318">said</a>:</p>
<blockquote>
<p>which kind of sounds like it might be what you're doing</p>
</blockquote>
<p>That definitely makes it sound like more work than what I did is required to actually do this correctly. My understanding of this code is quite poor.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>